/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author simon
 */
@Entity
@Table(name = "country")
@NamedQueries({
    @NamedQuery(name = "Country.findAll", query = "SELECT c FROM Country c"),
    @NamedQuery(name = "Country.findByIdcountry", query = "SELECT c FROM Country c WHERE c.idcountry = :idcountry"),
    @NamedQuery(name = "Country.findByName", query = "SELECT c FROM Country c WHERE c.name = :name")})
public class Country implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idcountry")
    private Integer idcountry;
    @Column(name = "name")
    private String name;
    @Column (name= "local_iso")
    private String localIso;
    @JoinColumn(name = "currency_id", referencedColumnName = "idCurrency")
    @ManyToOne(optional = false)
    private Currency currency;

    public Country() {
    }

    public Country(Integer idcountry) {
        this.idcountry = idcountry;
    }

    public Integer getIdcountry() {
        return idcountry;
    }

    public void setIdcountry(Integer idcountry) {
        this.idcountry = idcountry;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    public String getLocalIso() {
        return localIso;
    }

    public void setLocalIso(String localIso) {
        this.localIso = localIso;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcountry != null ? idcountry.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Country)) {
            return false;
        }
        Country other = (Country) object;
        if ((this.idcountry == null && other.idcountry != null) || (this.idcountry != null && !this.idcountry.equals(other.idcountry))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.dao.hbm.Country[idcountry=" + idcountry + "; name="+ name +"; Currency=" + currency +"]";
    }

}
